package com.tamecode.resource;

import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;

import java.io.IOException;

/**
 * classpath: 与 classpath*: 的区别
 *      classpath 只会查找当前工程中的资源，而 classpath*: 会扫描当前工程所有 jar 包下的资源
 *
 * @Author: LiQiongchao
 * @Date: 2021/8/5 20:27
 */
public class PatternResolverTest {

    public static void main(String[] args) throws IOException {

        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();

        // 在所有的 jar 包下查找 com.tamecode包下（及间接包下） .xml 为后缀的资源
//        Resource[] resources = resolver.getResources("classpath*:com/tamecode/**/*.xml");
        Resource[] resources = resolver.getResources("classpath*:**/*.xml");

        for (Resource resource : resources) {
            System.out.println(resource.getDescription());
        }
        /*
        file [D:\WorkSpaces\practise-projects\spring-4.x-learn\chapter04-Ioc\target\classes\applicationContext.xml]
        URL [jar:file:/D:/develop/Java/jdk1.8.0_102/jre/lib/deploy.jar!/com/sun/deploy/panel/settings.xml]
        URL [jar:file:/D:/develop/Java/jdk1.8.0_102/jre/lib/ext/jfxrt.jar!/com/sun/javafx/font/android_system_fonts.xml]
         */

    }

}
